package com.bomberman.environment;

import java.awt.Color;
import java.util.*;

import info.gridworld.actor.*;
import info.gridworld.grid.*;
import info.gridworld.gui.*;
import info.gridworld.world.*;

public class Shelter extends Tile
//invincible square, BOOMs can't enter
{
	private Man P;
	private int timer;
	
	public Shelter(BombWorld world, Location Loc)
	{super(world, Loc);
	open = false;
	setColor(Color.darkGray);}
	
	public void got(Man Player)
	{P = Player; timer = 3;}
	
	public void act()
	//death timer doesn't work
	{timer--; if(timer==0) getMan().dead();}
	
	public void run()
	{}
	
	public boolean in(Actor occupant)
	{
		if(occupant.getClass().equals(Man.class))
			return in(((Man) occupant));
		else
			return false;
	}
	
	public boolean in(Man occupant)
	{
		if(P==null)
		{
			P = occupant;
			setColor(P.getClr());
			return true;
		}
		else
			return false;
	}
	
	public Man out()
	{
		if(P == null)
			return null;
		
		setColor(Color.darkGray);
		Man p = P;
		p.inTile = false;
		p.Loc = getLocation();
		P = null;
		return p;
	}
	
	public Man getMan()
	{return P;}
}